package com.wq.gof.designer.lessif;

/**
 * @Author: wangqiang20995
 * @Date:2019/8/7
 * @Description:使用枚举来实现减少if-else
 * @Resource:
 */
public class Calculator {

    public int calculator(int a,int b,Operator operator){
        return operator.apply(a,b);
    }

    public static void main(String[] args){
        Calculator calculator = new Calculator();
        int result = calculator.calculator(1,2,Operator.ADD);
        System.out.println(result);
    }
}
